package com.bytedance.frameworks.baselib.a;

import android.content.Context;

import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

public final class e {
    final Map<String, b> a;
    final AtomicBoolean b;
    private static e c;
    private final Context d;
    private final f e;
    private final LinkedList<c> f;

    private e(Context arg5) {
        this.b = new AtomicBoolean(false);
        this.f = new LinkedList();
        this.d = arg5.getApplicationContext();
        this.a = new ConcurrentHashMap();
        this.e = new f(this.d, this, this.f, this.b);
        this.e.start();
    }

    public static e a(Context arg2) {
        if (c == null) {
            Class v1 = e.class;
            synchronized (v1) {
                if (c == null) {
                    c = new e(arg2);
                }
            }
        }

        return c;
    }

    final b a(String arg2) {
        return this.a.get(arg2);
    }

    public final boolean a(String arg5, byte[] arg6) {
        f v2;
        boolean v0 = false;
        if (!this.b.get() && arg6 != null && arg6.length > 0 && this.a(arg5) != null) {
            LinkedList v1 = this.f;
            synchronized (v1) {
                if (this.b.get()) {
                    return false;
                } else {
                    if (this.f.size() >= 2000) {
                        this.f.poll();
                    }
                    v0 = this.f.add(new c(arg5, arg6));
                    v2 = this.e;
                }
            }
            synchronized (v2.a) {
                v2.a.notify();
            }
        }
        return v0;

    }
}

